<template>
  <div id="JGGCSGZLYSB">
    <p style="text-align: center; margin: 10px 0">结构工程施工质量验收表</p>
    <table border="1" width="100%">
      <!--<tr>-->
      <!--<td>工程名称</td>-->
      <!--<td colspan="2">-->
      <!--<el-input size="mini" v-model="DJJCData.GCMC"></el-input>-->
      <!--</td>-->
      <!--<td>结构类型</td>-->
      <!--<td colspan="2">-->
      <!--<el-input size="mini" v-model="DJJCData.JGLX"></el-input>-->
      <!--</td>-->
      <!--</tr>-->
      <!--<tr>-->
      <!--<td>工程地点</td>-->
      <!--<td colspan="2">-->
      <!--<el-input size="mini" v-model="DJJCData.GCDD"></el-input>-->
      <!--</td>-->
      <!--<td>层数</td>-->
      <!--<td colspan="2">-->
      <!--<el-input size="mini" v-model="DJJCData.CS"></el-input>-->
      <!--</td>-->
      <!--</tr>-->
      <!--<tr>-->
      <!--<td>建筑面积</td>-->
      <!--<td colspan="4">-->
      <!--<el-input size="mini" v-model="DJJCData.JZMJ"></el-input>-->
      <!--</td>-->
      <!--</tr>-->
      <!--<tr>-->
      <!--<td>设计单位（人员）</td>-->
      <!--<td colspan="5">-->
      <!--<el-input size="mini" v-model="DJJCData.SJDW"></el-input>-->
      <!--</td>-->
      <!--</tr>-->
      <!--<tr>-->
      <!--<td>施工单位（人员）</td>-->
      <!--<td colspan="5">-->
      <!--<el-input size="mini" v-model="DJJCData.SGDW"></el-input>-->
      <!--</td>-->
      <!--</tr>-->
      <!--<tr>-->
      <!--<td>业主</td>-->
      <!--<td colspan="5">-->
      <!--<el-input size="mini" v-model="DJJCData.YZ"></el-input>-->
      <!--</td>-->
      <!--</tr>-->
      <tr>
        <td colspan="2" rowspan="2">验收部位</td>
        <td colspan="2">施工单位（工匠）检査结果</td>
        <td colspan="2">业主验收结论</td>
      </tr>
      <tr>
        <td colspan="2">合格 | 不合格</td>
        <td colspan="2">合格 | 不合格</td>
      </tr>
      <tr>
        <td colspan="2">地基和基础</td>
        <td colspan="2">
          <!--<van-field-->
          <!--style="font-size: 16px"-->
          <!--v-model="DJJCData.SGDWDJJC"-->
          <!--/>-->
          <van-radio-group v-model="DJJCData.SGDWDJJC">
            <van-radio :name="1">合格</van-radio>
            <van-radio :name="0">不合格</van-radio>
          </van-radio-group>
        </td>
        <td colspan="2">
          <van-radio-group v-model="DJJCData.YZDJHJC">
            <van-radio :name="1">合格</van-radio>
            <van-radio :name="0">不合格</van-radio>
          </van-radio-group>
          <!--<van-field-->
          <!--style="font-size: 16px"-->
          <!--v-model="DJJCData.YZDJHJC"-->
          <!--/>-->
        </td>
      </tr>
      <tr>
        <td colspan="2">墙体</td>
        <td colspan="2">
          <!--<van-field-->
          <!--style="font-size: 16px"-->
          <!--v-model="DJJCData.SGDWQT"-->
          <!--/>-->
          <van-radio-group v-model="DJJCData.SGDWQT">
            <van-radio :name="1">合格</van-radio>
            <van-radio :name="0">不合格</van-radio>
          </van-radio-group>
          <!--<el-input size="mini" v-model="DJJCData.SGDWQT"></el-input>-->
        </td>
        <td colspan="2">
          <van-radio-group v-model="DJJCData.YZQT">
            <van-radio :name="1">合格</van-radio>
            <van-radio :name="0">不合格</van-radio>
          </van-radio-group>
          <!--<van-field-->
          <!--style="font-size: 16px"-->
          <!--v-model="DJJCData.YZQT"-->
          <!--/>-->
          <!--<el-input size="mini" v-model="DJJCData.YZQT"></el-input>-->
        </td>
      </tr>
      <tr>
        <td colspan="2">楼盖</td>
        <td colspan="2">
          <van-radio-group v-model="DJJCData.SGDWLG">
            <van-radio :name="1">合格</van-radio>
            <van-radio :name="0">不合格</van-radio>
          </van-radio-group>
          <!--<van-field-->
          <!--style="font-size: 16px"-->
          <!--v-model="DJJCData.SGDWLG"-->
          <!--/>-->
          <!--<el-input size="mini" v-model="DJJCData.SGDWLG"></el-input>-->
        </td>
        <td colspan="2">
          <!--<van-field-->
          <!--style="font-size: 16px"-->
          <!--v-model="DJJCData.YZLG"-->
          <!--/>-->
          <van-radio-group v-model="DJJCData.YZLG">
            <van-radio :name="1">合格</van-radio>
            <van-radio :name="0">不合格</van-radio>
          </van-radio-group>
          <!--<el-input size="mini" v-model="DJJCData.YZLG"></el-input>-->
        </td>
      </tr>
      <tr>
        <td colspan="2">屋盖</td>
        <td colspan="2">
          <!--<van-field-->
          <!--style="font-size: 16px"-->
          <!--v-model="DJJCData.SGDWWG"-->
          <!--/>-->
          <van-radio-group v-model="DJJCData.SGDWWG">
            <van-radio :name="1">合格</van-radio>
            <van-radio :name="0">不合格</van-radio>
          </van-radio-group>
          <!--<el-input size="mini" v-model="DJJCData.SGDWWG"></el-input>-->
        </td>
        <td colspan="2">
          <!--<van-field-->
          <!--style="font-size: 16px"-->
          <!--v-model="DJJCData.YZWG"-->
          <!--/>-->
          <van-radio-group v-model="DJJCData.YZWG">
            <van-radio :name="1">合格</van-radio>
            <van-radio :name="0">不合格</van-radio>
          </van-radio-group>
          <!--<el-input size="mini" v-model="DJJCData.YZWG"></el-input>-->
        </td>
      </tr>
      <tr>
        <td colspan="2">结构观感</td>
        <td colspan="2">
          <!--<van-field-->
          <!--style="font-size: 16px"-->
          <!--v-model="DJJCData.SGDWJGGG"-->
          <!--/>-->
          <van-radio-group v-model="DJJCData.SGDWJGGG">
            <van-radio :name="1">合格</van-radio>
            <van-radio :name="0">不合格</van-radio>
          </van-radio-group>
          <!--<el-input size="mini" v-model="DJJCData.SGDWJGGG"></el-input>-->
        </td>
        <td colspan="2">
          <!--<van-field-->
          <!--style="font-size: 16px"-->
          <!--v-model="DJJCData.YZJGGG"-->
          <!--/>-->
          <van-radio-group v-model="DJJCData.YZJGGG">
            <van-radio :name="1">合格</van-radio>
            <van-radio :name="0">不合格</van-radio>
          </van-radio-group>
          <!--<el-input size="mini" v-model="DJJCData.YZJGGG"></el-input>-->
        </td>
      </tr>
      <tr>
        <td colspan="2">验收意见</td>
        <td colspan="4">
          <van-field style="font-size: 16px" v-model="DJJCData.YSYJ" />
          <!--<el-input size="mini" v-model="DJJCData.YSYJ"></el-input>-->
        </td>
      </tr>
      <tr v-for="(item1, index1) in ImgData" :key="index1">
        <td style="text-align: left; padding: 10px" colspan="8">
          <span style="margin-right: 40%">{{ item1.name }}</span>
          <p>
            <van-uploader @click-upload="getList(item1)" :after-read="afterRead" :before-delete="delectFile"
              v-model="item1.fileList" multiple />
          </p>
        </td>
      </tr>
      <tr>
        <td colspan="6">
          <p>
            <!-- <van-field style="font-size: 16px" v-model="DJJCData.SJDWYJ" placeholder="请填写设计单位（人员）" label="设计单位（人员）：" /> -->
            <qianzi :placeholder="'请手写设计单位(人员)'" :file="fileshouxie" :GROUPGUID="'结构工程施工质量验收表_设计单位检查人员'" :ROW_GUID="rowGuid"></qianzi>
            <!--<el-input-->
            <!--v-model="DJJCData.SJDWYJ"-->
            <!--size="mini"-->
            <!--style="width: calc(100% - (144px + 5px))"-->
            <!--&gt;</el-input>-->
          </p>
          <div style="text-align: right">
            <van-field readonly clickable name="datetimePicker" :value="DJJCData.SJDWSJ" label="检查时间："
              placeholder="请选择检查时间" @click="showPicker = true" style="font-size: 16px" />
            <van-popup v-model="showPicker" position="bottom">
              <van-datetime-picker v-model="currentDate" type="date" title="选择年月日" @cancel="showPicker = false"
                @confirm="onConfirmR" />
            </van-popup>
          </div>
        </td>
      </tr>
      <tr>
        <td colspan="6">
          <p>
            <!-- <van-field style="font-size: 16px" v-model="DJJCData.SGDWYJ" placeholder="请填写施工单位（工匠）" label=" 施工单位（工匠）：" /> -->
            <qianzi :placeholder="'请填写施工单位（工匠）'" :file="fileshouxie1" :GROUPGUID="'结构工程施工质量验收表_施工单位检查人员'" :ROW_GUID="rowGuid"></qianzi>
            <!--<el-input-->
            <!--v-model="DJJCData.SGDWYJ"-->
            <!--size="mini"-->
            <!--style="width: calc(100% - (144px + 5px))"-->
            <!--&gt;</el-input>-->
          </p>
          <!--<div style="text-align: right">-->
          <van-field readonly clickable name="datetimePicker" :value="DJJCData.SGDWSJ" label="检查时间：" placeholder="请选择检查时间"
            @click="showPicker1 = true" style="font-size: 16px" />
          <van-popup v-model="showPicker1" position="bottom">
            <van-datetime-picker v-model="currentDate" type="date" title="选择年月日" @cancel="showPicker1 = false"
              @confirm="onConfirmR1" />
          </van-popup>
          <!--</div>-->
        </td>
      </tr>
      <tr>
        <td colspan="6">
          <p>
            <!-- <van-field style="font-size: 16px" v-model="DJJCData.YZYJ" label="业主：" placeholder="请填写业主" /> -->
            <qianzi :placeholder="'请填写业主'" :file="fileshouxie2" :GROUPGUID="'结构工程施工质量验收表_业主检查人员'" :ROW_GUID="rowGuid"></qianzi>
            <!--<el-input-->
            <!--v-model="DJJCData.YZYJ"-->
            <!--size="mini"-->
            <!--style="width: calc(100% - (48px + 5px))"-->
            <!--&gt;</el-input>-->
          </p>
          <div style="text-align: right">
            <van-field readonly clickable name="datetimePicker" :value="DJJCData.YZSJ" label="检查时间：" placeholder="请选择检查时间"
              @click="showPicker2 = true" style="font-size: 16px" />
            <van-popup v-model="showPicker2" position="bottom">
              <van-datetime-picker v-model="currentDate" type="date" title="选择年月日" @cancel="showPicker2 = false"
                @confirm="onConfirmR2" />
            </van-popup>
          </div>
        </td>
      </tr>
      <tr>
        <td colspan="6">
          <p>
            <!--<el-input-->
            <!--size="mini"-->
            <!--v-model="DJJCData.XGRYYJ"-->
            <!--style="width: calc(100% - (80px + 5px))"-->
            <!--&gt;</el-input>-->
            <!-- <van-field style="font-size: 16px" v-model="DJJCData.XGRYYJ" placeholder="请填写相关人员" label="相关人员：" /> -->
            <qianzi :placeholder="'请填写相关人员'" :file="fileshouxie3" :GROUPGUID="'结构工程施工质量验收表_相关人员'" :ROW_GUID="rowGuid"></qianzi>
          </p>
          <div style="text-align: right">
            <van-field readonly clickable name="datetimePicker" :value="DJJCData.XGRYSJ" label="检查时间："
              placeholder="请选择检查时间" @click="showPicker3 = true" style="font-size: 16px" />
            <van-popup v-model="showPicker3" position="bottom">
              <van-datetime-picker v-model="currentDate" type="date" title="选择年月日" @cancel="showPicker3 = false"
                @confirm="onConfirmR3" />
            </van-popup>
          </div>
        </td>
      </tr>
    </table>
    <div class="footer" v-if="!$route.query.type">
      <van-button style="margin-right: 10px" size="small" type="info" @click="handleClick(SaveData)"
        v-if="this.$store.state.isGJ">提交</van-button>
      <van-button v-if="!this.$store.state.isGJ" size="small" type="info" @click="save()">保存</van-button>
    </div>
    <van-popup v-model="shoulm1">
      <div class="con_box">
        <h3>{{ text1.title }}</h3>
        <p>{{ text1.message }}</p>
        <div class="btnv">
          <span @click="handleClose1()" v-if="text1.btn.cancelText">
            {{
              text1.btn.cancelText
            }}
          </span>
          <span @click="handleOk1(SaveData)" v-if="text1.btn.okText">
            {{
              text1.btn.okText
            }}
          </span>
        </div>
      </div>
    </van-popup>
    <van-popup v-model="shoulm">
      <div class="con_box">
        <h3>{{ text.title }}</h3>
        <p>{{ text.message }}</p>
        <div class="btnv">
          <span @click="handleClose()" v-if="text.btn.cancelText">{{
            text.btn.cancelText
          }}</span>
          <span @click="handleOk(SaveData)" v-if="text.btn.okText">{{
            text.btn.okText
          }}</span>
        </div>
      </div>
    </van-popup>
  </div>
</template>

<script>
import {
  InsertDataView,
  dataServerOpenDataView,
  updateDataView,
  FileServerUpload,
  GetFileData,
  DelectFile,
  FileServerProxy,
  dataTransFile,
  dataTransFilePreview
} from "../../../utils/api";
import qianzi from '../../../common/qianzi.vue'
export default {
  name: "JGGCSGZLYSB",
  data() {
    return {
      rowGuid: "",
      fileshouxie: [
        {
          title: '请手写设计单位(人员)',
          groupGuid: '结构工程施工质量验收表_设计单位检查人员',
          FileName: '无',
          fileList: [],
        },
      ],
      fileshouxie1: [
        {
          title: '请填写施工单位(工匠)',
          FileName: '无',
          groupGuid: '结构工程施工质量验收表_施工单位检查人员',
          fileList: [],
        },
      ],
      fileshouxie2: [
        {
          title: '请填写业主',
          FileName: '无',
          groupGuid: '结构工程施工质量验收表_业主检查人员',
          fileList: [],
        },
      ],
      fileshouxie3: [
        {
          title: '请填写相关人员',
          FileName: '无',
          groupGuid: '结构工程施工质量验收表_相关人员',
          fileList: [],
        },
      ],
      ImgData: [
        {
          name: "钢筋合格证照片",
          groupGuid: "100d5a8d-16e3-4f6a-a1cf-7e84f0db23f2",
          fileList: [],
        },
        {
          name: "水泥合格证照片",
          groupGuid: "db7e9969-2ac1-42ff-905d-48614ba61160",
          fileList: [],
        },
        {
          name: "石子沙合格证照片",
          groupGuid: "a6437bd1-5121-46f6-aaf9-7221cb27e13e",
          fileList: [],
        },
        {
          name: "现场照片合格证照片",
          groupGuid: "09baf471-856a-4ccd-9479-6ff23718dd74",
          fileList: [],
        },
      ],
      showPicker: false,
      showPicker1: false,
      showPicker2: false,
      showPicker3: false,
      currentDate: new Date(),
      rowData: "",
      SaveData: "",
      DJJCData: {
        SGDWDJJC: 1,
        YZDJHJC: 1,
        SGDWQT: 1,
        YZQT: 1,
        SGDWLG: 1,
        YZLG: 1,
        SGDWWG: 1,
        YZWG: 1,
        SGDWJGGG: 1,
        YZJGGG: 1,
        SJDWSJ: "",
        XGRYSJ: "",
        SGDWSJ: "",
        YZSJ: "",
        SJDWYJ: ''
      },
      isAdd: true,
      shoulm: false,
      text: {
        title: "提示",
        message: "请确认是否发起竣工验收验收申请?",
        btn: {
          okText: "确定",
          cancelText: "取消",
        },
      },
      text1: {
        title: '提示',
        message: '请确认是否需要更换工匠?',
        btn: {
          okText: '确定',
          cancelText: '取消'
        }
      },
      shoulm1: false,
      IsSaveYS: false,
    };
  },
  methods: {
    handleClose() {

      this.shoulm = false;
    },
    handleClose1() {
      if (this.IsSaveYS) {
        this.shoulm = true
      } else {
        this.$toast.fail("工匠无提交《结构工程施工质量验收表》表单！");
        this.shoulm1 = false;
      }
    },
    handleOk1(data) {

      // this.handleButton();
      //更换工匠 标识
      window.sessionStorage.setItem('ChangeGJ', true)
      //跳入更换工匠页面
      this.$router.push({
        path: "craftsmanServices",
        query: {
          id1: '更换工匠',
          dataValue: JSON.stringify(this.tableData)
        }
      });
    },
    handleOk(data) {
      this.save('提交')
      if (this.$store.state.isGJ) {
        if (
          (this.$store.state.HJZT === 4 && data.proc_name != "定位放样") ||
          (this.$store.state.HJZT === 6 && data.proc_name != "基槽验线") ||
          (this.$store.state.HJZT === 8 && data.proc_name != "一层立模") ||
          (this.$store.state.HJZT === 7 && data.proc_name != "竣工验收")
        ) {
          this.$toast.fail("未到此环节!");
          // this.$notify({ type: "warning", message: "未到此环节!" });
        }
        if (this.$store.state.HJZT === 4 && data.proc_name == "定位放样") {
          //调用定位放样的接口
          // let parms = {
          //   bizGuid: '9ae6659d-523b-4572-b808-17c469e8eec1',
          //   wfGuid: '{612C9C60-8D18-4D23-BF32-E9D9D01BB0EA}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          setTimeout(() => {
            this.$router.push({
              path: "/TreeSelectZL",
              query: {
                data: { TASK_ID: this.tableData, isdwfy: 1 },
                data2: "定位放样",
              },
            });
          }, 500);
        } else if (
          this.$store.state.HJZT === 6 &&
          data.proc_name == "基槽验线"
        ) {
          // let parms = {
          //   bizGuid: '475c5d81-e6aa-486f-a113-bd651a675d75',
          //   wfGuid: '{460B4B5F-C3C2-4D4D-A702-17D4B4A3252F}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          setTimeout(() => {
            this.$router.push({
              path: "/TreeSelectZL",
              query: {
                data: { TASK_ID: this.tableData, isjcyx: 1 },
                data2: "基槽验线",
              },
            });
          }, 500);
        } else if (
          this.$store.state.HJZT === 8 &&
          data.proc_name == "一层立模"
        ) {
          // let parms = {
          //   bizGuid: '21bbc961-f41f-4a9a-827b-491ec569bc0e',
          //   wfGuid: '{7F042B34-7091-4884-A5D6-A615AE55497D}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          setTimeout(() => {
            this.$router.push({
              path: "/TreeSelectZL",
              query: {
                data: { TASK_ID: this.tableData, isyclm: 1 },
                data2: "一层立模",
              },
            });
          }, 500);
        } else if (
          this.$store.state.HJZT === 7 &&
          data.proc_name == "竣工验收"
        ) {
          // let parms = {
          //   bizGuid: '647a2885-7dc1-44af-b57d-2d63c4ab2936',
          //   wfGuid: '{8FAD71FB-7756-4F0A-BEE8-4F6397B075A8}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          setTimeout(() => {
            this.$router.push({
              path: "/TreeSelectZL",
              query: {
                data: { TASK_ID: this.tableData, isjgys: 1 },
                data2: "竣工验收",
              },
            });
          }, 500);
        }
      } else {
        if (
          (this.$store.state.HJZT === 4 && data.proc_name != "定位放样") ||
          (this.$store.state.HJZT === 6 && data.proc_name != "基槽验线") ||
          (this.$store.state.HJZT === 8 && data.proc_name != "一层立模") ||
          (this.$store.state.HJZT === 7 && data.proc_name != "竣工验收")
        ) {
          this.$toast.fail("未到此环节!");
          // this.$notify({ type: "warning", message: "未到此环节!" });
        }
        if (this.$store.state.HJZT === 4 && data.proc_name == "定位放样") {
          //调用定位放样的接口
          // let parms = {
          //   bizGuid: '9ae6659d-523b-4572-b808-17c469e8eec1',
          //   wfGuid: '{612C9C60-8D18-4D23-BF32-E9D9D01BB0EA}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          window.localStorage.setItem("isNHCW", 1);
          setTimeout(() => {
            this.$router.push({
              path: "/TreeSelect",
              query: {
                data: this.tableData,
              },
            });
          }, 500);
        } else if (
          this.$store.state.HJZT === 6 &&
          data.proc_name == "基槽验线"
        ) {
          // let parms = {
          //   bizGuid: '475c5d81-e6aa-486f-a113-bd651a675d75',
          //   wfGuid: '{460B4B5F-C3C2-4D4D-A702-17D4B4A3252F}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          window.localStorage.setItem("isNHCW", 1);
          setTimeout(() => {
            this.$router.push({
              path: "/TreeSelect",
              query: {
                data: this.tableData,
              },
            });
          }, 500);
        } else if (
          this.$store.state.HJZT === 8 &&
          data.proc_name == "一层立模"
        ) {
          // let parms = {
          //   bizGuid: '21bbc961-f41f-4a9a-827b-491ec569bc0e',
          //   wfGuid: '{7F042B34-7091-4884-A5D6-A615AE55497D}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          window.localStorage.setItem("isNHCW", 1);
          setTimeout(() => {
            this.$router.push({
              path: "/TreeSelect",
              query: {
                data: this.tableData,
              },
            });
          }, 500);
        } else if (
          this.$store.state.HJZT === 7 &&
          data.proc_name == "竣工验收"
        ) {
          // let parms = {
          //   bizGuid: '647a2885-7dc1-44af-b57d-2d63c4ab2936',
          //   wfGuid: '{8FAD71FB-7756-4F0A-BEE8-4F6397B075A8}',
          //   entityRowGuid: this.tableData.ROW_GUID,
          //   token: window.localStorage.getItem('token')
          // }
          // const res = await CreateProcessAndSendTask(parms);
          window.localStorage.setItem("isNHCW", 1);
          setTimeout(() => {
            this.$router.push({
              path: "/TreeSelect",
              query: {
                data: this.tableData,
              },
            });
          }, 500);
        }
      }
    },
    delectFile: async function (file) {
      // if (file.ROW_GUID) {
      //   const res = await DelectFile({
      //     fileGuid: file.ROW_GUID,
      //     token: window.localStorage.getItem("token"),
      //   });
      // }
      // if (file.ROW_GUID) {
      //   let params = {
      //     "accessCode": "ce9b691634de4ebca68dc5bb638d07f4",
      //     "cityCode": "441300000000",
      //     "params": {
      //       "fileGuid": file.ROW_GUID,
      //       token: window.localStorage.getItem('token')
      //     }
      //   }
      //   const res = await FileServerProxy(params)
      // }
      let fileguid = "";
      if (file.ROW_GUID) {
        fileguid = file.ROW_GUID;
      } else {
        fileguid = this.fileGuid;
      }
      if (fileguid) {
        let params = {
          accessCode: "ce9b691634de4ebca68dc5bb638d07f4",
          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "441300000000",
          params: {
            fileGuid: fileguid,
          },
        };
        const res = await FileServerProxy(params);
        let data = JSON.parse(res.data.data).Success;
        if (data) {
          this.$toast.success("删除成功!");
        }
      }
    },
    afterRead(file) {
      this.getFileServerUpload(file.file);
    },
    getFile: async function () {
      let groupGuid = [];
      this.ImgData.forEach((item) => {
        groupGuid.push(item.groupGuid);
      });
      // const res1 = await GetFileData({
      //   groupGuid: groupGuid.join(","),
      //   toRowGuid: this.rowGuid,
      // });
      // if (res1.data.FilesInfo.length > 0) {
      //   res1.data.FilesInfo.forEach((element) => {
      //     this.ImgData.forEach((items) => {
      //       if (element.GROUPGUID == items.groupGuid) {
      //         element["isImage"] = true;
      //         element["url"] =
      //           window.g.BaseURL +
      //           "FileServer/api/Preview?token=" +
      //           window.localStorage.getItem("token") +
      //           "&" +
      //           "fileGuid=" +
      //           encodeURIComponent(element.ROW_GUID);
      //         items.fileList.push(element);
      //       }
      //     });
      //   });
      // }
      let params = {
        accessCode: "1fdcbce42c6d4748a020feba618d54b8",
        cityCode: window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "441300000000",
        params: {
          groupGuid: groupGuid.join(","),
          toRowGuid: this.rowGuid,
        },
      };
      const res = await FileServerProxy(params);
      let data = JSON.parse(res.data.data).FilesInfo;
      if (data.length > 0) {
        data.forEach((element) => {
          this.ImgData.forEach((items) => {
            if (element.GROUPGUID == items.groupGuid) {
              this.getFileUrl(element, items);
              // element["isImage"] = true;
              // element["url"] =
              //   window.g.BaseURL +
              //   "FileServer/api/Preview?token=" +
              //   window.localStorage.getItem("token") +
              //   "&" +
              //   "fileGuid=" +
              //   encodeURIComponent(element.ROW_GUID);
              // items.fileList.push(element);
            }
          });
        });
      }
    },
    //获取附件文件流
    getFileUrl: async function (element, item) {
      let formData = new FormData();
      formData.append("accessCode", "98bcf528966e48ce896a8b3fd02d45d5");
      formData.append(
        "cityCode",
        window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "441300000000"
      );
      formData.append(
        "paramStr",
        JSON.stringify({
          fileGuid: element.ROW_GUID,
        })
      );
      let response = await dataTransFilePreview(formData);
      if (response) {
        var img = new Blob([new Int8Array(response.data, 0)], {
          type: response.headers["content-type"],
        }); //type类型可自定义
        element["isImage"] = true;
        element["url"] = window.URL.createObjectURL(img);
        item.fileList.push(element);
      }
    },
    getFileServerUpload: async function (file) {
      let data = {
        toRowGuid: this.rowGuid,
        groupGuid: this.groupGuids,
      };
      let formData = new FormData();
      formData.append("file", file);
      // formData.append("toRowGuid", this.rowGuid);
      // formData.append("groupGuid", this.groupGuids);
      // formData.append("token", window.localStorage.getItem("token"));
      formData.append("accessCode", "7a3fc061c866434b8475d3775c9ddcea");
      formData.append("cityCode", window.localStorage.getItem("citycode")
        ? window.localStorage.getItem("citycode")
        : "441300000000");
      formData.append("paramStr", JSON.stringify(data));
      const res = await dataTransFile(formData);
      let data1 = JSON.parse(res.data.data).FileList;
      this.fileGuid = data1[0].FILEGUID;
      if (data1[0].FILEGUID) {
        this.$toast.success("上传成功!");
      }
      if (res.data.Success == true) {
        this.$toast.success("上传成功!");
      }
    },
    getList(item) {
      this.groupGuids = item.groupGuid;
    },
    handleClick: async function (data) {
      debugger
      console.log(this.DJJCData, 'dnuifneiu')
      //调用当前环节的接口
      // this.shoulm1 = true;
      // this.tableData?.OPTYPE == '59'?this.shoulm1 = true:this.shoulm = true
      // if (this.tableData?.OPTYPE == '59') {
      //   //更换工匠 标识1
      //   this.$confirm({
      //     title: '提示',
      //     message: '请确认是否需要更换工匠？',
      //     btn: {
      //       okText: '确定',
      //       cancelText: '取消'
      //     }
      //   })
      //     .then(() => {
      //       // do something
      //       window.sessionStorage.setItem('ChangeGJ', true)
      //       //跳入更换工匠页面
      //       this.$router.push({
      //         path: 'craftsmanServices',
      //         query: {
      //           id1: '更换工匠',
      //           dataValue: JSON.stringify(this.tableData),
      //         },
      //       })
      //     })
      //     .catch(() => {
      //       console.log('no')
      //     })
      // } else {
        this.shoulm = true
      // }
    },
    getData: async function () {
      // let dataGuid = "4627bb7e-468c-406e-a95b-42c9a4972460";
      // let searchObject = encodeURIComponent(
      //   JSON.stringify([
      //     { field: "to_row_guid", value: this.rowData.ROW_GUID, operator: "=" },
      //   ])
      // );
      // let token = window.localStorage.getItem("token");
      // const res = await dataServerOpenDataView(dataGuid, searchObject, token);
      // if (res.data.Data.length > 0) {
      //   this.DJJCData = res.data.Data[0];
      //   this.ROW_GUID = res.data.Data[0].ROW_GUID;
      //   this.isAdd = false;
      // } else {
      //   this.ROW_GUID = this.newGuid();
      //   this.isAdd = true;
      // }

      let params = {
        accessCode: "688bd3883572440a859dfd8ba9194e7b",
        cityCode: window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "441300000000",
        params: {
          dataguid: "4627bb7e-468c-406e-a95b-42c9a4972460",
          searchObject: JSON.stringify([
            {
              field: "to_row_guid",
              value: this.rowData.ROW_GUID,
              operator: "=",
            },
          ]),
        },
      };
      const res = await FileServerProxy(params);
      let data = JSON.parse(res.data.data).Data;
      if (data.length > 0) {
        this.DJJCData = data[0];
        this.ROW_GUID = data[0].ROW_GUID;
        this.isAdd = false;
      } else {
        this.ROW_GUID = this.newGuid();
        this.isAdd = true;
      }
    },
    newGuid(format) {
      //表示全局唯一标识符 (GUID)。
      function Guid(g) {
        var arr = new Array(); //存放32位数值的数组
        if (typeof g == "string") {
          //如果构造函数的参数为字符串
          InitByString(arr, g);
        } else {
          InitByOther(arr);
        }
        //返回 Guid 类的此实例值的 String 表示形式。
        this.ToString = function (format) {
          if (typeof format == "string") {
            if (
              format == "N" ||
              format == "D" ||
              format == "B" ||
              format == "P"
            ) {
              return ToStringWithFormat(arr, format);
            } else {
              return ToStringWithFormat(arr, "D");
            }
          } else {
            return ToStringWithFormat(arr, "D");
          }
        };

        //由字符串加载
        function InitByString(arr, g) {
          g = g.replace(/\{|\(|\)|\}|-/g, "");
          g = g.toLowerCase();
          if (g.length != 32 || g.search(/[^0-9,a-f]/i) != -1) {
            InitByOther(arr);
          } else {
            for (var i = 0; i < g.length; i++) {
              arr.push(g[i]);
            }
          }
        }

        //由其他类型加载
        function InitByOther(arr) {
          // var i = 32;
          // while (i--) {
          //     arr.push("0");
          // }

          var i = 32;
          while (i--) {
            arr.push(Math.floor(Math.random() * 16.0).toString(16));
          }
        }

        /*
            根据所提供的格式说明符，返回此 Guid 实例值的 String 表示形式。
            N  32 位： xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
            D  由连字符分隔的 32 位数字 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
            B  括在大括号中、由连字符分隔的 32 位数字：{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
            P  括在圆括号中、由连字符分隔的 32 位数字：(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
            */

        //增加一个标识能区分开这个guid是不是由前端生成的
        function ToStringWithFormat(arr, format) {
          switch (format) {
            case "N":
              return arr.toString().replace(/,/g, "");
            case "D":
              var str =
                arr.slice(0, 8) +
                "-1203" +
                "-" +
                arr.slice(12, 16) +
                "-" +
                arr.slice(16, 20) +
                "-" +
                arr.slice(20, 32);
              str = str.replace(/,/g, "");
              return str;
            case "B":
              var str = ToStringWithFormat(arr, "D");
              str = "{" + str + "}";
              return str;
            case "P":
              var str = ToStringWithFormat(arr, "D");
              str = "(" + str + ")";
              return str;
            default:
              return new Guid();
          }
        }

        return this.ToString();
      }

      var g = new Guid();
      return g.ToString(format);
    },
    //判断验收表单信息是否填写
    getDataIsSaveYS: async function () {
      let I_ROW_GUID = "'" + this.rowGuid + "'";
      let ghjbrexIsSaveYS = {
        procName: "up_query",
        dtParams: JSON.stringify([{ I_USERID: I_ROW_GUID, I_TYPE: 9 }]),
        token: window.localStorage.getItem("token"),
      };
      let ghjbrfuIsSaveYS = {
        accessCode: "69db6bece3a7480592e2ec753d1e335e",
        cityCode: window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "441300000000",
        params: ghjbrexIsSaveYS,
      };
      const resghjbrbeisSaveYS = await FileServerProxy(ghjbrfuIsSaveYS);
      let IssaveDataYS = JSON.parse(resghjbrbeisSaveYS.data.data);
      if (IssaveDataYS.Data && IssaveDataYS.Data.length > 0 && IssaveDataYS.Data[0].DATA == 0) {
        this.IsSaveYS = false;
      } else {
        this.IsSaveYS = true;
      }
    },
    save: async function (type) {
      // let data = this.DJJCData;
      // data.ROW_GUID = this.ROW_GUID;
      // data.TO_ROW_GUID = this.rowData.ROW_GUID;
      // let params = {
      //   dataGuid: "4627bb7e-468c-406e-a95b-42c9a4972460",
      //   strParams: JSON.stringify([data]),
      //   token: window.localStorage.getItem("token"),
      // };
      // if (this.isAdd) {
      //   const res = await InsertDataView(params);
      //   if (res.data.Success) {
      //     this.$toast.success('成功！');
      //     // this.$notify({ type: "success", message: "成功!" });
      //   }
      // } else {
      //   const res = await updateDataView(params);
      //   if (res.data.Success) {
      //     this.$toast.success('修改成功!');
      //     // this.$notify({ type: "success", message: "修改成功!" });
      //   }
      // }

      let data = this.DJJCData;
      data.ROW_GUID = this.ROW_GUID;
      data.TO_ROW_GUID = this.rowData.ROW_GUID;
      let params = {
        accessCode: "",
        cityCode: window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "441300000000",
        params: {
          dataGuid: "4627bb7e-468c-406e-a95b-42c9a4972460",
          strParams: JSON.stringify([data]),
        },
      };
      if (this.isAdd) {
        params.accessCode = "0fb3f6123d1b4fe6851c99532c463f6f";
        const res = await FileServerProxy(params);
        let data = JSON.parse(res.data.data).Success;
        if (data && !type) { //点击提交的不提示
          this.$toast.success('成功！')
        }
      } else {
        params.accessCode = "77ad6c1591e54d4fbc45ecc90374a2a2";
        const res = await FileServerProxy(params);
        let data = JSON.parse(res.data.data).Success;
        if (data && !type) { //点击提交的不提示
          this.$toast.success('成功！')
        }
        // if (res.data.Success) {
        //   this.$toast.success('修改成功!');
        // }
      }
    },
    onConfirmR(val) {
      let year = val.getFullYear();
      let month = val.getMonth() + 1;
      let day = val.getDate();
      let hour = val.getHours();
      let minute = val.getMinutes();
      if (month >= 1 && month <= 9) {
        month = `0${month}`;
      }
      if (day >= 1 && day <= 9) {
        day = `0${day}`;
      }
      if (hour >= 0 && hour <= 9) {
        hour = `0${hour}`;
      }
      if (minute >= 0 && minute <= 9) {
        minute = `0${minute}`;
      }
      this.DJJCData.SJDWSJ = `${year}-${month}-${day}`;
      this.showPicker = false;
    },
    onConfirmR1(val) {
      let year = val.getFullYear();
      let month = val.getMonth() + 1;
      let day = val.getDate();
      let hour = val.getHours();
      let minute = val.getMinutes();
      if (month >= 1 && month <= 9) {
        month = `0${month}`;
      }
      if (day >= 1 && day <= 9) {
        day = `0${day}`;
      }
      if (hour >= 0 && hour <= 9) {
        hour = `0${hour}`;
      }
      if (minute >= 0 && minute <= 9) {
        minute = `0${minute}`;
      }
      this.DJJCData.SGDWSJ = `${year}-${month}-${day}`;
      this.showPicker1 = false;
    },
    onConfirmR2(val) {
      let year = val.getFullYear();
      let month = val.getMonth() + 1;
      let day = val.getDate();
      let hour = val.getHours();
      let minute = val.getMinutes();
      if (month >= 1 && month <= 9) {
        month = `0${month}`;
      }
      if (day >= 1 && day <= 9) {
        day = `0${day}`;
      }
      if (hour >= 0 && hour <= 9) {
        hour = `0${hour}`;
      }
      if (minute >= 0 && minute <= 9) {
        minute = `0${minute}`;
      }
      this.DJJCData.YZSJ = `${year}-${month}-${day}`;
      this.showPicker2 = false;
    },
    onConfirmR3(val) {
      let year = val.getFullYear();
      let month = val.getMonth() + 1;
      let day = val.getDate();
      let hour = val.getHours();
      let minute = val.getMinutes();
      if (month >= 1 && month <= 9) {
        month = `0${month}`;
      }
      if (day >= 1 && day <= 9) {
        day = `0${day}`;
      }
      if (hour >= 0 && hour <= 9) {
        hour = `0${hour}`;
      }
      if (minute >= 0 && minute <= 9) {
        minute = `0${minute}`;
      }
      this.DJJCData.XGRYSJ = `${year}-${month}-${day}`;
      this.showPicker3 = false;
    },
    defaultField() {
      let dateTime;
      let yy = new Date().getFullYear();
      let mm =
        new Date().getMonth() + 1 < 10
          ? "0" + (new Date().getMonth() + 1)
          : new Date().getMonth() + 1;
      let dd =
        new Date().getDate() < 10
          ? "0" + new Date().getDate()
          : new Date().getDate();
      dateTime = yy + "-" + mm + "-" + dd;
      this.DJJCData.SJDWSJ = dateTime;
      this.DJJCData.XGRYSJ = dateTime;
      this.DJJCData.SGDWSJ = dateTime;
      this.DJJCData.YZSJ = dateTime;
    },
  },
  mounted() {
    this.defaultField();
    this.rowData = JSON.parse(this.$route.query.data);
    this.rowGuid = this.rowData.ROW_GUID;
    this.tableData = JSON.parse(this.$route.query.data);
    this.SaveData = JSON.parse(this.$route.query.data1);
    this.getData();
    this.getFile();
    this.getDataIsSaveYS();
  },
  components: {
    qianzi
  }
};
</script>

<style lang="scss">
#JGGCSGZLYSB {
  .footer {
    text-align: center;
    padding: 10px 0;
  }

  height: 100vh;
  overflow: auto;

  .van-radio__label {
    width: 48px;
  }

  /*padding:  10px;*/
  table,
  table tr th,
  table tr td {
    border: 1px solid #000000;
    text-align: center;
  }

  .van-popup {
    border-radius: 10px;

    .con_box {
      width: 270px;
      line-height: 1;
      text-align: center;
      color: #4d5c82;
      padding: 15px;
      box-sizing: border-box;

      >h3 {
        font-size: 20px;
        margin-top: 10px;
        margin-bottom: 20px;
      }

      >p {
        font-size: 17px;
        margin-bottom: 30px;
      }

      .btnv {
        display: flex;
        justify-content: space-between;

        >span {
          display: block;
          width: 114px;
          background-color: #e0e5f5;
          text-align: center;
          line-height: 44px;
          font-size: 17px;
        }

        >span:last-of-type {
          background-color: #1288fe;
          color: #ffffff;
        }
      }
    }
  }
}
</style>
